package edu.school.utils;

import java.util.Map;

/**
 * @author kabuda
 * @create 2023-09-30 17:10
 */
public class R {
    private boolean success;
    private int code; //0正确 1错误
    private String msg;
    private Map<String,Object> data;


    public static R success(){
      R r= new R();
      r.success=true;
      r.code=0;
      r.msg="成功";
      return  r;
    }
    public static R data(Map<String,Object> data){
      R r= new R();
      r.success=true;
      r.code=0;
      r.msg="成功";
      r.data=data;
      return  r;
    }
    public static R fail(){
      R r= new R();
      r.success=false;
      r.code=1;
      r.msg="失败";
      return  r;
    }

    public R() {
    }

    public R(boolean success, int code, String msg, Map<String, Object> data) {
        this.success = success;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "R{" +
                "success=" + success +
                ", code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
